/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class Transaction
    {
    
        private String transactionIdField;

        private String sellerIdField;

        private String conditionField;

        private String transactionDateField;

        private String transactionDateEpochField;

        private String sellerNameField;

        private String payingCustomerIdField;

        private String orderingCustomerIdField;

        private  TransactionTotals totalsField;
        private  TransactionItems transactionItemsField;
        private  TransactionShipments shipmentsField;

        /// <summary>
        /// Gets and sets the TransactionId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TransactionId")]
        public String TransactionId
        {
            get { return this.transactionIdField ; }
            set { this.transactionIdField= value; }
        }



        /// <summary>
        /// Sets the TransactionId property
        /// </summary>
        /// <param name="transactionId">TransactionId property</param>
        /// <returns>this instance</returns>
        public Transaction WithTransactionId(String transactionId)
        {
            this.transactionIdField = transactionId;
            return this;
        }



        /// <summary>
        /// Checks if TransactionId property is set
        /// </summary>
        /// <returns>true if TransactionId property is set</returns>
        public Boolean IsSetTransactionId()
        {
            return  this.transactionIdField != null;

        }


        /// <summary>
        /// Gets and sets the SellerId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "SellerId")]
        public String SellerId
        {
            get { return this.sellerIdField ; }
            set { this.sellerIdField= value; }
        }



        /// <summary>
        /// Sets the SellerId property
        /// </summary>
        /// <param name="sellerId">SellerId property</param>
        /// <returns>this instance</returns>
        public Transaction WithSellerId(String sellerId)
        {
            this.sellerIdField = sellerId;
            return this;
        }



        /// <summary>
        /// Checks if SellerId property is set
        /// </summary>
        /// <returns>true if SellerId property is set</returns>
        public Boolean IsSetSellerId()
        {
            return  this.sellerIdField != null;

        }


        /// <summary>
        /// Gets and sets the Condition property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Condition")]
        public String Condition
        {
            get { return this.conditionField ; }
            set { this.conditionField= value; }
        }



        /// <summary>
        /// Sets the Condition property
        /// </summary>
        /// <param name="condition">Condition property</param>
        /// <returns>this instance</returns>
        public Transaction WithCondition(String condition)
        {
            this.conditionField = condition;
            return this;
        }



        /// <summary>
        /// Checks if Condition property is set
        /// </summary>
        /// <returns>true if Condition property is set</returns>
        public Boolean IsSetCondition()
        {
            return  this.conditionField != null;

        }


        /// <summary>
        /// Gets and sets the TransactionDate property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TransactionDate")]
        public String TransactionDate
        {
            get { return this.transactionDateField ; }
            set { this.transactionDateField= value; }
        }



        /// <summary>
        /// Sets the TransactionDate property
        /// </summary>
        /// <param name="transactionDate">TransactionDate property</param>
        /// <returns>this instance</returns>
        public Transaction WithTransactionDate(String transactionDate)
        {
            this.transactionDateField = transactionDate;
            return this;
        }



        /// <summary>
        /// Checks if TransactionDate property is set
        /// </summary>
        /// <returns>true if TransactionDate property is set</returns>
        public Boolean IsSetTransactionDate()
        {
            return  this.transactionDateField != null;

        }


        /// <summary>
        /// Gets and sets the TransactionDateEpoch property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TransactionDateEpoch")]
        public String TransactionDateEpoch
        {
            get { return this.transactionDateEpochField ; }
            set { this.transactionDateEpochField= value; }
        }



        /// <summary>
        /// Sets the TransactionDateEpoch property
        /// </summary>
        /// <param name="transactionDateEpoch">TransactionDateEpoch property</param>
        /// <returns>this instance</returns>
        public Transaction WithTransactionDateEpoch(String transactionDateEpoch)
        {
            this.transactionDateEpochField = transactionDateEpoch;
            return this;
        }



        /// <summary>
        /// Checks if TransactionDateEpoch property is set
        /// </summary>
        /// <returns>true if TransactionDateEpoch property is set</returns>
        public Boolean IsSetTransactionDateEpoch()
        {
            return  this.transactionDateEpochField != null;

        }


        /// <summary>
        /// Gets and sets the SellerName property.
        /// </summary>
        [XmlElementAttribute(ElementName = "SellerName")]
        public String SellerName
        {
            get { return this.sellerNameField ; }
            set { this.sellerNameField= value; }
        }



        /// <summary>
        /// Sets the SellerName property
        /// </summary>
        /// <param name="sellerName">SellerName property</param>
        /// <returns>this instance</returns>
        public Transaction WithSellerName(String sellerName)
        {
            this.sellerNameField = sellerName;
            return this;
        }



        /// <summary>
        /// Checks if SellerName property is set
        /// </summary>
        /// <returns>true if SellerName property is set</returns>
        public Boolean IsSetSellerName()
        {
            return  this.sellerNameField != null;

        }


        /// <summary>
        /// Gets and sets the PayingCustomerId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "PayingCustomerId")]
        public String PayingCustomerId
        {
            get { return this.payingCustomerIdField ; }
            set { this.payingCustomerIdField= value; }
        }



        /// <summary>
        /// Sets the PayingCustomerId property
        /// </summary>
        /// <param name="payingCustomerId">PayingCustomerId property</param>
        /// <returns>this instance</returns>
        public Transaction WithPayingCustomerId(String payingCustomerId)
        {
            this.payingCustomerIdField = payingCustomerId;
            return this;
        }



        /// <summary>
        /// Checks if PayingCustomerId property is set
        /// </summary>
        /// <returns>true if PayingCustomerId property is set</returns>
        public Boolean IsSetPayingCustomerId()
        {
            return  this.payingCustomerIdField != null;

        }


        /// <summary>
        /// Gets and sets the OrderingCustomerId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "OrderingCustomerId")]
        public String OrderingCustomerId
        {
            get { return this.orderingCustomerIdField ; }
            set { this.orderingCustomerIdField= value; }
        }



        /// <summary>
        /// Sets the OrderingCustomerId property
        /// </summary>
        /// <param name="orderingCustomerId">OrderingCustomerId property</param>
        /// <returns>this instance</returns>
        public Transaction WithOrderingCustomerId(String orderingCustomerId)
        {
            this.orderingCustomerIdField = orderingCustomerId;
            return this;
        }



        /// <summary>
        /// Checks if OrderingCustomerId property is set
        /// </summary>
        /// <returns>true if OrderingCustomerId property is set</returns>
        public Boolean IsSetOrderingCustomerId()
        {
            return  this.orderingCustomerIdField != null;

        }


        /// <summary>
        /// Gets and sets the Totals property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Totals")]
        public TransactionTotals Totals
        {
            get { return this.totalsField ; }
            set { this.totalsField = value; }
        }



        /// <summary>
        /// Sets the Totals property
        /// </summary>
        /// <param name="totals">Totals property</param>
        /// <returns>this instance</returns>
        public Transaction WithTotals(TransactionTotals totals)
        {
            this.totalsField = totals;
            return this;
        }



        /// <summary>
        /// Checks if Totals property is set
        /// </summary>
        /// <returns>true if Totals property is set</returns>
        public Boolean IsSetTotals()
        {
            return this.totalsField != null;
        }




        /// <summary>
        /// Gets and sets the TransactionItems property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TransactionItems")]
        public TransactionItems TransactionItems
        {
            get { return this.transactionItemsField ; }
            set { this.transactionItemsField = value; }
        }



        /// <summary>
        /// Sets the TransactionItems property
        /// </summary>
        /// <param name="transactionItems">TransactionItems property</param>
        /// <returns>this instance</returns>
        public Transaction WithTransactionItems(TransactionItems transactionItems)
        {
            this.transactionItemsField = transactionItems;
            return this;
        }



        /// <summary>
        /// Checks if TransactionItems property is set
        /// </summary>
        /// <returns>true if TransactionItems property is set</returns>
        public Boolean IsSetTransactionItems()
        {
            return this.transactionItemsField != null;
        }




        /// <summary>
        /// Gets and sets the Shipments property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Shipments")]
        public TransactionShipments Shipments
        {
            get { return this.shipmentsField ; }
            set { this.shipmentsField = value; }
        }



        /// <summary>
        /// Sets the Shipments property
        /// </summary>
        /// <param name="shipments">Shipments property</param>
        /// <returns>this instance</returns>
        public Transaction WithShipments(TransactionShipments shipments)
        {
            this.shipmentsField = shipments;
            return this;
        }



        /// <summary>
        /// Checks if Shipments property is set
        /// </summary>
        /// <returns>true if Shipments property is set</returns>
        public Boolean IsSetShipments()
        {
            return this.shipmentsField != null;
        }






        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetTransactionId()) {
                xml.Append("<TransactionId>");
                xml.Append(EscapeXML(this.TransactionId));
                xml.Append("</TransactionId>");
            }
            if (IsSetSellerId()) {
                xml.Append("<SellerId>");
                xml.Append(EscapeXML(this.SellerId));
                xml.Append("</SellerId>");
            }
            if (IsSetCondition()) {
                xml.Append("<Condition>");
                xml.Append(EscapeXML(this.Condition));
                xml.Append("</Condition>");
            }
            if (IsSetTransactionDate()) {
                xml.Append("<TransactionDate>");
                xml.Append(EscapeXML(this.TransactionDate));
                xml.Append("</TransactionDate>");
            }
            if (IsSetTransactionDateEpoch()) {
                xml.Append("<TransactionDateEpoch>");
                xml.Append(EscapeXML(this.TransactionDateEpoch));
                xml.Append("</TransactionDateEpoch>");
            }
            if (IsSetSellerName()) {
                xml.Append("<SellerName>");
                xml.Append(EscapeXML(this.SellerName));
                xml.Append("</SellerName>");
            }
            if (IsSetPayingCustomerId()) {
                xml.Append("<PayingCustomerId>");
                xml.Append(EscapeXML(this.PayingCustomerId));
                xml.Append("</PayingCustomerId>");
            }
            if (IsSetOrderingCustomerId()) {
                xml.Append("<OrderingCustomerId>");
                xml.Append(EscapeXML(this.OrderingCustomerId));
                xml.Append("</OrderingCustomerId>");
            }
            if (IsSetTotals()) {
                TransactionTotals  totals = this.Totals;
                xml.Append("<Totals>");
                xml.Append(totals.ToXMLFragment());
                xml.Append("</Totals>");
            } 
            if (IsSetTransactionItems()) {
                TransactionItems  transactionItems = this.TransactionItems;
                xml.Append("<TransactionItems>");
                xml.Append(transactionItems.ToXMLFragment());
                xml.Append("</TransactionItems>");
            } 
            if (IsSetShipments()) {
                TransactionShipments  shipments = this.Shipments;
                xml.Append("<Shipments>");
                xml.Append(shipments.ToXMLFragment());
                xml.Append("</Shipments>");
            } 
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}